using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.Data.Filtering;
using DevExpress.Xpo;
namespace ChuanPlus.FormControl
{
    public partial class ControlCustomer : DevExpress.XtraEditors.XtraUserControl
    {
        public ControlCustomer()
        {
            InitializeComponent();
        }

        private void textFilter_EditValueChanged(object sender, EventArgs e)
        {
            CriteriaOperator filter = new BinaryOperator(new OperandProperty("CustomerName"),new OperandValue("%" + textFilter.Text + "%"),BinaryOperatorType.Like);
            xpColCustomer.Filter = filter;
        }

        private void buttonInsert_Click(object sender, EventArgs e)
        {
            double credit = 0, creditLimit = 0;
            if (textCredit.Text != "")  Convert.ToDouble(textCredit.Text);
            if (textCreditLimit.Text != "") Convert.ToDouble(textCreditLimit.Text);
                
            Customer c = new Customer(Session.DefaultSession, textCustomer.Text, memoAddress.Text, textCPhone.Text, textFax.Text,creditLimit,credit, textOwner.Text, textOPhone.Text, textAccountant.Text, textAPhone.Text, comboPayment.Text);
            c.Save();
            
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }
    }
}
